<!DOCTYPE html>
<!-- saved from url=(0036)http://sinooceanlas.com/cate/10.html -->
<html lang="en" style="font-size: 40px;">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">



	<title>资产展示发布</title>
	<meta name="keywords" content="河北省企业投资理财协会">
	<meta name="description" content="河北省企业投资理财协会">

	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">

	<meta name="format-detection" content="telephone=no">

	<meta name="apple-mobile-web-app-capable" content="yes">

	<meta name="apple-mobile-web-app-status-bar-style" content="black">

	<meta name="referrer" content="never">

	<link rel="stylesheet" href="./comment/layui.css">

	<link rel="stylesheet" type="text/css" media="screen and (min-width:320px) and (max-width:760px)"
		href="./comment/phone.css">

	<link rel="stylesheet" type="text/css" media="screen and (min-width:760px) and (max-width:3600px)"
		href="./comment/pc.css">

	<link rel="stylesheet" type="text/css" href="./comment/reset.css">

	<link rel="stylesheet" type="text/css" href="./comment/animate.css">

	<link rel="stylesheet" type="text/css" href="./comment/swiper.min.css">

	<script type="text/javascript" src="./comment/rem.js"></script>


	<link rel="stylesheet" href="./comment/layer.css" id="layuicss-layer">
	

</head>

<body style="font-size: 12px;">

	<div id="app">
		<my-header></my-header>
		<div class="gg_ban">
			<img src="./img/bcg_top_2.JPG">
		</div>

		<div class="com_one">
			<div class="wow bounceInDown com_one_t" style="visibility: visible; animation-name: bounceInDown;">
				<p>发布资产</p>
				<p>Publish assets</p>
				<span></span>
			</div>
			<div class="com_one_b">
				<div class="wow bounceInLeft com_one_b_l" style="visibility: visible; animation-name: bounceInLeft;">
					<form class="info_tj">
						<div class="com_one_b_l_li">
							<p><span>*</span>资产名称</p>
							<div>
								<input v-model="form.name" type="text" name="tel" placeholder="请输入资产名称">
							</div>
						</div>
						<!-- <div class="com_one_b_l_li">
							<p><span>*</span>资产图片</p>
							<div style="border: none;padding-top: 10px;">
								<input @change="uploadFile" accept="image/*" type="file" id="fileInput" name="file">
							</div>
						</div> -->
						<div class="com_one_b_l_li">
							<p><span>*</span>所在地区</p>
							<div style="margin-bottom: 10px;"> 
								<select @change="provinceChange" name="yuanqu">
									<option v-for="(item,index) in provinceList" :key="index" :value="item.province_id">{{item.province_name}}</option>
								</select>
							</div>
							<p><span>*</span></p>
							<div style="margin-bottom: 10px;">
								<select @change="cityChange" name="yuanqu">
									<option v-for="(item,index) in cityList" :key="index" :value="item.city_id">{{item.city_name}}</option>
								</select>
							</div>
							<p ><span>*</span></p>
							<div>
								<select name="yuanqu">
									<option v-for="(item,index) in countyList" :key="index" :value="item.county_id">{{item.county_name}}</option>
								</select>
							</div>
							
						</div>
						<div class="com_one_b_l_li">
							<p><span>*</span>合作方式</p>
							<div>
								<select @change="cooperationChange" name="cooperation">
									<option value="1">租赁</option>
									<option value="2">买卖</option>
									<option value="3">其他</option>
								</select>
							</div>
						</div>
						<div class="com_one_b_l_li com_one_b_l_li_text">
							<p><span>*</span>资产描述</p>
							<div>
								<textarea v-model="form.describe" name="content" placeholder="请输入资产描述"></textarea>
							</div>
						</div>
					
						<div class="com_one_b_l_li com_one_b_l_li_text">
							<span style="font-family:宋体;color: #000;font-size: 13px;">
								<strong>提交成功后，需要后台管理审核，有问题请联系我们：{{comanyInfo.mobile}}</strong>
							</span>
						</div>
						
						<div @click="submit" class="com_one_b_l_f tj_btn">提交</div>
					</form>
				</div>
			</div>
		</div>
		<my-footer></my-footer>
	</div>
	<script type="text/javascript" src="./comment/jquery-2.1.4.min.js"></script>
	<script src="./js/vue.js"></script>
	<script src="js/comment.js"></script>
	<script type="text/javascript" src="./comment/layer.js"></script>
	<script>
		var app = new Vue({
			el: '#app',
			data: {
				form:{
					name:'',
					describe:'',
					image_list:[],
					province_id:'',
					city_id:'',
					county_id:'',
					mode: '1', // 默认租赁
				},
				provinceList:[],
				cityList:[],
				countyList:[],
				provinceId:'',
				cityId:'',
				countyId:'',
				userinfo:{},
				comanyInfo:{}
			},
			mounted () {
				let userinfoStr = localStorage.getItem('userinfo')
				this.userinfo = JSON.parse(userinfoStr)
				if(userinfoStr=='undefined'||userinfoStr==null) { window.location.href = './login.html'}
				document.getElementById('assetShowPage').classList.add('gg_nav_r_r_ac')
				this.getProvince()
				this.getCompanyInfo()
			},
			methods: {
				uploadFile() {
					let that = this
					var fileInput = document.getElementById('fileInput');
					var file = fileInput.files[0]; // 获取文件对象
				
					var formData = new FormData();
					formData.append('file', file); // 将文件添加到formData对象中
				
					var xhr = new XMLHttpRequest();
					xhr.open('POST', gloabApi+'/common/upload', true); // 指定上传的URL和方法
					xhr.onload = function (res) {
						let resData = JSON.parse(res.target.response)
						console.log(resData)
						if(resData.code===1){
							that.form.image_list.push(resData.data.url)
							console.log(that.form)
							console.log('文件上传成功');
							layer.msg('文件上传成功',{icon:1});
						}else{
							layer.msg(resData.msg);
						}
						
					};
					xhr.send(formData); // 发送formData对象
				},
				provinceChange(e){
					this.provinceId = e.target.value
					this.getCityList(this.provinceId)
				},
				cityChange(e){
					this.cityId = e.target.value
					this.getCountyList(this.cityId)
				},
				getProvince () {
					const that = this
					// var indexlayer = layer.load(2);
					$.ajax({
						type: 'get',
						url: gloabApi + "/Common/getProvinceList",
						data: {},
						dataType: 'json',
						success: function (res) {
							if (res.code == 1) {
								console.log((res))
								that.provinceList = res.data
								that.provinceId = res.data[0].province_id
								that.getCityList(that.provinceId)
							} else {
								// layer.msg(res.msg);
							}
							// layer.close(indexlayer);
						},
					})
				},
				getCityList (provinceId) {
					const that = this
					// var indexlayer = layer.load(2);
					$.ajax({
						type: 'get',
						url: gloabApi + "/Common/getCityList",
						data: {province_id:provinceId},
						dataType: 'json',
						success: function (res) {
							if (res.code == 1) {
								console.log((res))
								that.cityList = res.data
								that.cityId = that.cityList[0].city_id
								that.getCountyList(that.cityId)
							} else {
								// layer.msg(res.msg);
							}
							// layer.close(indexlayer);
						},
					})
				},
				getCountyList(cityId) {
					
					const that = this
					// var indexlayer = layer.load(2);
					$.ajax({
						type: 'get',
						url: gloabApi + "/Common/getCountyList",
						data: {city_id:cityId},
						dataType: 'json',
						success: function (res) {
							if (res.code == 1) {
								console.log((res))
								that.countyList = res.data
								that.countyId = res.data[0].county_id
							} else {
								layer.msg(res.msg);
							}
							layer.close(indexlayer);
						},
					})
				},
				cooperationChange(e) {
					this.form.mode = e.target.value	
				},
				submit(){
					if(this.form.name===''){
						layer.msg('请输入资产名称');
						return
					}else if(this.provinceId===''||this.cityId===''||this.countyId===''){
						layer.msg('请选择所在地区');
						return
					}else if(this.form.describe===''){
						layer.msg('请输入资产描述');
						return
					}
					var indexlayer = layer.load(2);
					let that = this
					let params = {
						name:this.form.name,
						describe:this.form.describe,
						image_list:this.form.image_list,
						province_id:this.provinceId,
						city_id:this.cityId,
						county_id:this.countyId,
						mode: this.form.mode
					}
					$.ajax({
						type: 'post',
						url: gloabApi + "/Property/submit",
						data: params,
						headers:{token:that.userinfo.token},
						dataType: 'json',
						success: function (res) {
							console.log(res)
							layer.msg(res.msg);
							if (res.code == 1) {
								setTimeout(function () {
									window.location.href='./assetShow.html';
								}, 1000);
							} 
							layer.close(indexlayer);
						},
						error:function(res){
							layer.close(indexlayer);
							layer.msg(res.responseJSON.msg);
						}
					})
				},
				getCompanyInfo(){
					var that = this
					$.ajax({
						type: 'get',
						url: gloabApi + "/Companyinfo/getInfo",
						data: {},
						dataType: 'json',
						success: function (res) {
							if (res.code == 1) {
								that.comanyInfo = res.data
							} else {
								layer.msg(res.msg);
							}
						},
					})
				},
			}

		})
	</script>
	<script src="./js/login.js"></script>
	<script type="text/javascript" src="./comment/index.js"></script>
	<script type="text/javascript" src="./comment/wow.min.js"></script>
</body>

</html>